﻿using System;
using System.Linq.Expressions;
using System.Threading;
using System.Threading.Tasks;
using Microsoft.EntityFrameworkCore;
using WeatherHistory.Data.Entities;
using WeatherHistory.Data.Repositories.Interfaces;

namespace WeatherHistory.Data.Repositories;

public class RegionTypeRepository : RepositoryBase<RegionType>, IRegionTypeRepository
{
    public RegionTypeRepository(ApplicationDbContext context) : base(context)
    {
    }

    public async Task<RegionType> FirstOrDefaultWithRegionsAsync(Expression<Func<RegionType, bool>> match, CancellationToken cancellationToken)
    {
        return await DbSet
            .Include(x => x.Regions)
            .FirstOrDefaultAsync(match, cancellationToken);
    }
}